<?php


namespace App\Transformers;

use App\Models\Product;
use League\Fractal\TransformerAbstract;


/**
 *数据转换层
 */
class ProductTransformer extends TransformerAbstract
{

    public function transform(Product $product)
    {

        return [
            'id' => $product->id,
            'title' => $product->title,
            'description' => $product->description,
            'image' => $product->image,
            'on_sale' => $product->on_sale,
            'rating' => $product->rating,
            'sold_count' => $product->sold_count,
            'review_count' => $product->review_count,
            'price' => $product->price,
        ];
    }
}
